package com.example.server.controller;

import com.example.result.CommonResult;
import com.example.server.service.ComplaintUsersService;
import com.example.server.vo.ComplaintUsersVo;
import com.example.server.vo.ComplaintVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("complaintUsers")
public class ComplaintUsersController {
    @Autowired
    ComplaintUsersService complaintUsersService;
    /**
     * 投诉信息全查
     */
    @GetMapping("/getComplaintUsers")
    public List<ComplaintUsersVo> getComplaintUsers(){
        return complaintUsersService.getComplaintUsers();
    }
    /**
     * 投诉信息增改
     */
    @PostMapping("/saveOrUpdateComplaint")
    public CommonResult saveOrUpdateComplaint(@RequestBody ComplaintVo complaintVo){
        int i = complaintUsersService.saveOrUpdateComplaint(complaintVo);
        if(i>0){
            return CommonResult.ok();
        }else{
            return CommonResult.fail();
        }
    }
}
